home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / gamesmaster / source / asm / sound / playmodulo.s next >
Encoding:
Text File  |  1996-09-13  |  3.8 KB  |  156 lines

  1. ;Sound Effect Demo
  2. ;-----------------
  3. ;An example of modulating a sound sample.
  4. ;
  5. ;LMB plays the sound.
  6. ;RMB exits the demo.
  7.  
  8.     opt    o+
  9.  
  10.     INCLUDE    "exec/exec_lib.i"
  11.     INCLUDE    "games/games_lib.i"
  12.     INCLUDE    "games/games.i
  13.  
  14. CALL    MACRO
  15.     jsr    _LVO\1(a6)
  16.     ENDM
  17.  
  18.     SECTION    "Sound",CODE
  19.  
  20. ;==========================================================================;
  21. ;                             INITIALISE DEMO
  22. ;==========================================================================;
  23.  
  24. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  25.     move.l    ($4).w,a6
  26.     lea    GMS_Name(pc),a1
  27.     moveq    #$00,d0
  28.     CALL    OpenLibrary
  29.     move.l    d0,GMS_Base
  30.     beq    Quit
  31.  
  32.     move.l    GMS_Base(pc),a6
  33.     CALL    SetUserPri
  34.  
  35.     CALL    AllocAudio
  36.     tst.w    d0
  37.     bne.s    AudioError
  38.  
  39.     lea    Sound_Gong(pc),a0
  40.     CALL    InitSound
  41.     tst.w    d0
  42.     bne.s    AudioError
  43.  
  44. ;==========================================================================;
  45. ;                                MAIN LOOP
  46. ;==========================================================================;
  47.  
  48. MainLoop:
  49.     move.l    GMS_Base(pc),a6
  50.     CALL    Wait_OSVBL
  51.  
  52.     moveq    #JPORT1,d0
  53.     CALL    Read_Mouse
  54.     btst    #MB_RMB,d0
  55.     bne.s    ReturnDOS
  56.     btst    #MB_LMB,d0
  57.     beq.s    MainLoop
  58.  
  59.     lea    Sound_Gong(pc),a0
  60.     CALL    PlaySoundPri
  61.     lea    Sound_Modulus(pc),a0
  62.     CALL    PlaySoundPri
  63.  
  64. .release
  65.     moveq    #JPORT1,d0
  66.     CALL    Read_Mouse
  67.     btst    #MB_LMB,d0
  68.     bne.s    .release
  69.  
  70.     bra.s    MainLoop
  71.  
  72. ;===========================================================================;
  73. ;                              RETURN TO DOS
  74. ;===========================================================================;
  75.  
  76. ReturnDOS:
  77.     move.l    GMS_Base(pc),a6
  78.     CALL    FreeAudio
  79.     lea    Sound_Gong(pc),a0
  80.     CALL    FreeSound
  81. AudioError:
  82.     move.l    GMS_Base(pc),a1
  83.     move.l    ($4).w,a6
  84.     CALL    CloseLibrary
  85. Quit    MOVEM.L    (SP)+,A0-A6/D1-D7
  86.     moveq    #$00,d0
  87.     rts
  88.  
  89. ;===========================================================================;
  90. ;                                  DATA
  91. ;===========================================================================;
  92.  
  93. GMS_Name:
  94.     dc.b    "games.library",0
  95.     even
  96. GMS_Base:
  97.     dc.l    0
  98.  
  99. AMT_PLANES =    1
  100.  
  101. ScreenStruct:
  102.     dc.l    "GSV1",0
  103.     dc.l    0,0,0                    ;Screen_Mem1/2/3
  104.     dc.l    0                        ;Screen link.
  105.     dc.l    ScreenPalette            ;Address of screen palette.
  106.     dc.l    0                        ;Address of rasterlist.
  107.     dc.l    4                        ;Amt of colours in palette.
  108.     dc.w    320,256,320,256          ;Screen & Pic Height/Width.
  109.     dc.w    AMT_PLANES               ;Amt_Planes
  110.     dc.w    0,0                      ;Top Of Screen, X/Y
  111.     dc.w    0,0                      ;X/Y counters (for scrolling).
  112.     dc.l    0                        ;Special attributes.
  113.     dc.w    LORES                    ;Screen mode.
  114.     dc.b    INTERLEAVED              ;Screen type
  115.     dc.b    0                        ;Reserved
  116.     even
  117.  
  118. ScreenPalette:
  119.     dc.w    $0000,$0DDD,$0666,$0222
  120.  
  121. Sound_Modulus:
  122.     dc.l    "SMV1",0                 ;Structure version.
  123.     dc.w    CHANNEL1                 ;Channel to play through.
  124.     dc.w    1                        ;Priority
  125.     dc.l    0                        ;Header
  126.     dc.l    Modulus                  ;Address
  127.     dc.l    8                        ;Length
  128.     dc.w    OCT_A7S                  ;Period
  129.     dc.w    100                      ;Volume
  130.     dc.l    SBIT8|SREPEAT|SMODPER    ;Attributes
  131.     dc.l    0    ;File
  132.  
  133. Sound_Gong:
  134.     dc.l    "SMV1",0                 ;Structure version.
  135.     dc.w    CHANNEL2                 ;Channel to play through.
  136.     dc.w    1                        ;Priority
  137.     dc.l    Gong                     ;Header
  138.     dc.l    0                        ;Address
  139.     dc.l    0                        ;Length
  140.     dc.w    OCT_C2S                  ;Period
  141.     dc.w    100                      ;Volume
  142.     dc.l    SBIT8    ;Attributes
  143.     dc.l    Gong    ;File
  144.  
  145. Gong:    dc.b    "GAMESLIB:data/IFF.Lightning",0
  146.     even
  147.  
  148. ;===========================================================================;
  149. ;                            SOUND DATA (CHIP)
  150. ;===========================================================================;
  151.  
  152.     SECTION    "SoundArea",DATA_C
  153.  
  154. Modulus: dc.w    600,550,500,450,400,450,500,550
  155.  
  156.